-
-
Notifications
You must be signed in to change notification settings - Fork 47.5k
Weierstrass Method #12877
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Weierstrass Method #12877
Conversation
- Implements Durand-Kerner (Weierstrass) method for polynomial root finding - Accepts user-defined polynomial function and degree - Uses random perturbation of complex roots of unity for initial guesses - Handles validation, overflow clipping, and includes doctest
Preparing review... |
3 similar comments
Preparing review... |
Preparing review... |
Preparing review... |
Currently, the method always runs max_iter iterations. Adding a tolerance (tol) and stopping early when updates are small would improve efficiency. |
For stability, sometimes using deflation or derivative checks helps avoid stagnation on multiple roots. Could be an optional enhancement. |
Constructing the full denominator matrix (degree x degree) is O(n²). |
Great feedback, @MrittikaDutta ! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good 👍
Requires some additional tests ideally with higher order, handling floats, does this algorithm handle complex roots, etc
If you add some more tests or commit my tests I'll merge this pr.
* add more tests
for more information, see https://pre-commit.ci
Describe your change:
This pull request adds an implementation of the Weierstrass (Durand–Kerner) method to numerically approximate all complex roots of a given polynomial. The function accepts a user-defined polynomial, its degree, and an optional initial guess for the roots. The implementation includes:
Type annotations and detailed docstring
Doctest to validate correctness
Optional support for custom initial guesses
Numerical safeguards (e.g., overflow clipping)
A Wikipedia reference for further explanation
This method is useful in numerical analysis and computational algebra for finding all roots of a polynomial simultaneously using iterative refinement.
Checklist: